home *** CD-ROM | disk | FTP | other *** search
- Path: news.th-darmstadt.de!news
- From: Enno Sandner <enno@intellektik.informatik.th-darmstadt.de>
- Newsgroups: comp.lang.c++
- Subject: Re: Why use private class members instead of protected?
- Date: Thu, 11 Jan 1996 13:54:12 +0100
- Organization: Fachbereich Informatik, TH Darmstadt
- Message-ID: <30F50874.15FB7483@intellektik.informatik.th-darmstadt.de>
- References: <30F4AB49.6ABB@sierra.net>
- NNTP-Posting-Host: kitz.intellektik.informatik.th-darmstadt.de
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0b4 (X11; I; SunOS 4.1.3 sun4m)
-
- TGColwell wrote:
- >
- > I'm relatively new to c++. I have one quick question: If child
- > classes can only access protected members of the parent class,
- > why make any members of any class private? Wouldn't it be
- > better to make members of the parent class protected so that the
- > class is alway "inheritance ready"?
- >
-
- No,
- it's quite often a better approach to make these data-members private and
- provide the suitable accessor functions. In this way you can change the
- representation of the data-members without the problem that modifications
- will 'propagate' downwards the class-hierachie.
-
- Enno
-